﻿using SLClient;
using SLClient.Extension;
using SLClient.ServiceAPI;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;

namespace SLClient.CustomerControls
{
    public partial class BetControl : UserControl
    {
        private BetType _currentBetType;
        private int _lotteryCatagory;
        private BetDataControl m_BetDataControl = new BetDataControl();
        private BonusControl m_BonusControl;
        private BetPlayInfo m_CurrentBetPlayInfo;
        private BetPlayTypeInfo m_CurrentBetPlayTypeInfo;
        private List<CheckBox[]> m_CurrentCheckBoxs = new List<CheckBox[]>();
        private string[] m_PosNames;
        private BetPlayTypeInfo[] m_TypeInfos;
        private const int MaxBetCount = 0x3e8;
        private const int MaxBetDataLength = 0xfa0;
        private int playTypeId;
        private int playTypeInfoId;
        public double SelectNumberWidth = 96.0;
        private UserPlayInfo userInfo;

        public BetControl()
        {
            this.InitializeComponent();
            this.btAddBetNumber.Click+=new RoutedEventHandler(BtAddBetNumberClick);  
            this.btBet.Click+=new RoutedEventHandler(btBet_Click);
            this.listSelectedNumbers.SelectionChanged+=new SelectionChangedEventHandler(listSelectedNumbers_SelectionChanged); 
            this.btBonus.Click+=new RoutedEventHandler(btBonus_Click);    
            this.lbSelectCount.DataContext=m_BetDataControl;
            this.lbSelectCount.DataContext=this.m_BetDataControl;
            this.listSelectedNumbers.ItemsSource=this.m_BetDataControl.BetDatas;
            this.btnClear.Click+=new RoutedEventHandler(BtnClearClick);            
        }

        private void AddBetDataToList(string betdata)
        {
            if (this.m_CurrentBetPlayInfo != null)
            {
                if (string.IsNullOrWhiteSpace(betdata))
                {
                    App.Show("无效投注数据");
                }
                else if (betdata.Length > 0xfa0)
                {
                    App.Show("投注数据长度超过最大值");
                }
                else
                {
                    betdata = Regex.Replace(betdata.Trim(), @"[\s\$;，；]", ",");
                    if (Regex.IsMatch(betdata, @"[^\d,]"))
                    {
                        App.Show("投注数据含有非法字符");
                    }
                    else
                    {
                        string[] strArray;
                        if (this.m_CurrentBetPlayInfo.IsDouble > 0)
                        {
                            int betCount;
                            if (this.m_CurrentBetPlayInfo.BetType == 3)
                            {
                                strArray = betdata.Split(new char[] { ',' });
                                if (strArray.Length != this.m_CurrentBetPlayInfo.BetNumberCount)
                                {
                                    App.Show("号码不完整，无法添加");
                                    return;
                                }
                                betCount = Enumerable.Sum<string>(strArray, new Func<string, int>((s)=>{return s.Length;}));
                                if (betCount < 1)
                                {
                                    App.Show("没有选择任何投注号码");
                                    return;
                                }
                                this.m_BetDataControl.AddBetData(betCount, betdata, this.SelectNumberWidth);
                            }
                            else if (this.m_CurrentBetPlayInfo.BetType == 1)
                            {
                                betCount = CalControl.GetBetCount(this.m_CurrentBetPlayInfo.PlayId, betdata.Length);
                                if (betCount < 1)
                                {
                                    App.Show("号码不完整，无法添加");
                                    return;
                                }
                                this.m_BetDataControl.AddBetData(betCount, betdata, this.SelectNumberWidth);
                            }
                            else
                            {
                                strArray = betdata.Split(new char[] { ',' });
                                if (this.m_CurrentBetPlayInfo.BetNumberType == 0)
                                {
                                    if (strArray.Length != this.m_CurrentBetPlayInfo.BetNumberCount)
                                    {
                                        App.Show("号码不完整，无法添加");
                                        return;
                                    }
                                    betCount = 1;
                                    foreach (string str in strArray)
                                    {
                                        if (str.Length < 1)
                                        {
                                            App.Show("号码不完整，无法添加");
                                            return;
                                        }
                                        betCount *= str.Length;
                                    }
                                    this.m_BetDataControl.AddBetData(betCount, betdata, this.SelectNumberWidth);
                                }
                                else
                                {
                                    foreach (string str in strArray)
                                    {
                                        if (str.Length < 1)
                                        {
                                            App.Show("号码不完整，无法添加");
                                            return;
                                        }
                                    }
                                    this.m_BetDataControl.AddBetData(strArray.Length, betdata, this.SelectNumberWidth);
                                }
                            }
                        }
                        else
                        {
                            strArray = Regex.Split(betdata, "[,]+");
                            if (strArray.Length < 1)
                            {
                                App.Show("号码格式有误，无法添加");
                                return;
                            }
                            string str2 = "";
                            string pattern = @"^[\d]{" + this.m_CurrentBetPlayInfo.BetNumberCount + "}$";
                            for (int i = 0; i < strArray.Length; i++)
                            {
                                if (Regex.IsMatch(strArray[i], pattern))
                                {
                                    if ((this.m_CurrentBetPlayInfo.BetType == 1) && Comm.IsSameCharInString(strArray[i]))
                                    {
                                        int num3 = i + 1;
                                        App.Show("第" + num3.ToString() + "个号码 输入有错误");
                                        return;
                                    }
                                    if ((this.m_CurrentBetPlayInfo.BetType == 1) || (this.m_CurrentBetPlayInfo.BetType == 4))
                                    {
                                        strArray[i] = Comm.SortString(strArray[i]);
                                    }
                                    if (this.m_BetDataControl.ContainsBetData(strArray[i]))
                                    {
                                        string str4 = str2;
                                        string[] strArray2 = new string[] { str4, "第", (i + 1).ToString(), "个号码 ", strArray[i], " 已经在订单中\n" };
                                        str2 = string.Concat(strArray2);
                                    }
                                }
                                else
                                {
                                    App.Show("第" + (i + 1) + "个号码输入有误");
                                    return;
                                }
                            }
                            if (str2 != "")
                            {
                                str2 = str2 + "\n你确认再次添加吗?\n";
                                if (MessageBoxResult.OK != MessageBox.Show(str2, "确认", MessageBoxButton.OKCancel))
                                {
                                    return;
                                }
                            }
                            if (this.m_CurrentBetPlayInfo.BetType == 4)
                            {
                                foreach (string str in strArray)
                                {
                                    this.m_BetDataControl.AddBetData(new PL(str).Count, str, this.SelectNumberWidth);
                                }
                            }
                            else
                            {
                                foreach (string str in strArray)
                                {
                                    this.m_BetDataControl.AddBetData(1, str, this.SelectNumberWidth);
                                }
                            }
                        }
                        this.resetSelectNumber();
                    }
                }
            }
        }

        private void BounsEditWindowClosed(object sender, EventArgs e)
        {
            UserScaleInfo info = Enumerable.FirstOrDefault<UserScaleInfo>(ViewDispatcher.UserScaleInfos, 
                new Func<UserScaleInfo, bool>((s)=>{ return (s.PlayTypeInfoId == this.playTypeInfoId);}));
            if (info != null)
            {
                string format = ((info.JiangJin / 2M) > 100.0M) ? "F0" : (((info.JiangJin / 2M) > 10.0M) ? "F1" : "F2");
                this.lbBonus.Text=info.JiangJin.ToString(format);
                this.lbScale.Text=(info.JiangJin / 2M).ToString(format);
                this.lbBackPct.Text=info.FianDian.ToString("0.00%");
            }
        }

        private void BtAddBetNumberClick(object sender, RoutedEventArgs e)
        {
            if (this.m_CurrentBetPlayInfo != null)
            {
                if (this.m_CurrentBetPlayInfo.IsDouble > 0)
                {
                    string str;
                    int num;
                    string betdata = "";
                    if (this.m_CurrentBetPlayInfo.BetNumberType == 0)
                    {
                        for (int i = 0; i < this.m_CurrentCheckBoxs.Count; i++)
                        {
                            str = "";
                            num = 0;
                            while (num < this.m_CurrentCheckBoxs[i].Length)
                            {
                                if (this.m_CurrentCheckBoxs[i][num].IsChecked.Value)
                                {
                                    str = str + this.m_CurrentCheckBoxs[i][num].Content;
                                }
                                num++;
                            }
                            if (str != "")
                            {
                                betdata = betdata + str;
                            }
                            betdata = betdata + ",";
                        }
                        if (betdata.Length > 0)
                        {
                            betdata = betdata.Substring(0, betdata.Length - 1);
                        }
                    }
                    else
                    {
                        str = "";
                        for (num = 0; num < this.m_CurrentCheckBoxs[0].Length; num++)
                        {
                            if (this.m_CurrentCheckBoxs[0][num].IsChecked.Value)
                            {
                                str = str + this.m_CurrentCheckBoxs[0][num].Content+ ",";
                            }
                        }
                        if (str != "")
                        {
                            betdata = str.Substring(0, str.Length - 1);
                        }
                    }
                    this.AddBetDataToList(betdata);
                }
                else
                {
                    this.AddBetDataToList(this.tbNumbers.Text);
                }
            }
        }

        private void btAll_Click(object sender, RoutedEventArgs e)
        {
            CheckBox[] boxArray = (sender as Button).Tag as CheckBox[];
            if ((boxArray != null) && (boxArray.Length > 0))
            {
                foreach (CheckBox box in boxArray)
                {
                    box.IsChecked = true;
                }
            }
        }

        private void btBet_Click(object sender, RoutedEventArgs e)
        {
            if (this.m_CurrentBetPlayInfo == null)
            {
                App.Show("玩法信息有误");
            }
            else
            {
                decimal num;
                if (!(decimal.TryParse(this.tbAmount.Text, out num) && (num >= ViewDispatcher.CurrentConfig.MinBetMoney)))
                {
                    App.Show("投注分数有误");
                }
                else if (this.m_BetDataControl.BetCount < 1)
                {
                    App.Show("没有选择投注号码");
                }
                else if (this.m_BetDataControl.BetCount > 0x3e8)
                {
                    App.Show("单次投注数量超过上限(" + 0x3e8 + "注)");
                }
                else
                {
                    string betDatas = this.m_BetDataControl.GetBetDatas();
                    if (betDatas == "")
                    {
                        App.Show("没有选择投注号码");
                    }
                    else if (betDatas.Length > 0xfa0)
                    {
                        App.Show("投注数据长度超过上限(" + 0xfa0 + ")");
                    }
                    else
                    {
                        this.userInfo.DanBeiMoney = new decimal?(num);
                        this.userInfo.BetAmount = new int?(this.m_BetDataControl.BetCount);
                        this.userInfo.JiangJin = new decimal?(decimal.Parse(this.lbBonus.Text));
                        string str2 = this.lbBackPct.Text;
                        decimal num2 = decimal.Parse(str2.Substring(0, str2.IndexOf("%"))) / 100M;
                        this.userInfo.Fiandian = new decimal?(num2);
                        this.userInfo.Orization = this.m_CurrentBetPlayInfo.IsZx;
                        this.userInfo.PlayTypeId = this.m_CurrentBetPlayTypeInfo.TypeId;
                        this.userInfo.LotteryCatagoryId = this._lotteryCatagory;
                        this.userInfo.PlayTypeInfoId = this.m_CurrentBetPlayInfo.PlayId;
                        this.userInfo.UserId = ViewDispatcher.LoginUser.UserId;
                        this.userInfo.ContentNumber = this.m_BetDataControl.GetBetDatas();
                        this.userInfo.QIHao = this.m_BonusControl.Qihao;
                        ConfirmWindow window = new ConfirmWindow(this, null, this.userInfo, this.m_CurrentBetPlayTypeInfo.TypeName);
                        window.BetSuccess += new EventHandler(this.ConfirmWindowBetSuccess);
                        window.Show();
                    }
                }
            }
        }

        private void btBig_Click(object sender, RoutedEventArgs e)
        {
            CheckBox[] boxArray = (sender as Button).Tag as CheckBox[];
            if ((boxArray != null) && (boxArray.Length > 0))
            {
                for (int i = 0; i < boxArray.Length; i++)
                {
                    boxArray[i].IsChecked=new bool?(i >= (boxArray.Length / 2));
                }
            }
        }

        private void btBonus_Click(object sender, RoutedEventArgs e)
        {
            decimal jiangjin = decimal.Parse(this.lbBonus.Text);
            string str = this.lbBackPct.Text;
            decimal fandian = decimal.Parse(str.Substring(0, str.IndexOf("%"))) / 100M;
            BounsEditWindow window = new BounsEditWindow(this.playTypeId, this.playTypeInfoId, jiangjin, fandian);
            window.Closed += new EventHandler(this.BounsEditWindowClosed);
            window.Show();
        }

        private void btClear_Click(object sender, RoutedEventArgs e)
        {
            CheckBox[] boxArray = (sender as Button).Tag as CheckBox[];
            if ((boxArray != null) && (boxArray.Length > 0))
            {
                foreach (CheckBox box in boxArray)
                {
                    box.IsChecked = false;
                }
            }
        }

        private void btEven_Click(object sender, RoutedEventArgs e)
        {
            CheckBox[] boxArray = (sender as Button).Tag as CheckBox[];
            if ((boxArray != null) && (boxArray.Length > 0))
            {
                for (int i = 0; i < boxArray.Length; i++)
                {
                    boxArray[i].IsChecked = new bool?(((i + this.m_CurrentBetPlayInfo.MinNumber) % 2) == 0);
                }
            }
        }

        private void BtnClearClick(object sender, RoutedEventArgs e)
        {
            this.m_BetDataControl.ClearBetData();
        }

        private void btOdd_Click(object sender, RoutedEventArgs e)
        {
            CheckBox[] boxArray = (sender as Button).Tag as CheckBox[];
            if ((boxArray != null) && (boxArray.Length > 0))
            {
                for (int i = 0; i < boxArray.Length; i++)
                {
                    boxArray[i].IsChecked=new bool?(((i + this.m_CurrentBetPlayInfo.MinNumber) % 2) == 1);
                }
            }
        }

        private void btSmall_Click(object sender, RoutedEventArgs e)
        {
            CheckBox[] boxArray = (sender as Button).Tag as CheckBox[];
            if ((boxArray != null) && (boxArray.Length > 0))
            {
                for (int i = 0; i < boxArray.Length; i++)
                {
                    boxArray[i].IsChecked = new bool?(i < (boxArray.Length / 2));
                }
            }
        }

        private void ChgPlayTypeInfo(BetPlayTypeInfo bpti)
        {
            if (this.m_CurrentBetPlayTypeInfo != bpti)
            {
                this.m_CurrentBetPlayTypeInfo = bpti;
                this.playTypeId = bpti.TypeId;
                this.betPlayTypeCheckBoxs.Children.Clear();
                foreach (BetPlayInfo info in this.m_CurrentBetPlayTypeInfo.PlayInfos)
                {
                    RadioButton button = new RadioButton();
                    button.Content=info.PlayName;
                    button.DataContext = info;
                    button.Style = Application.Current.Resources["radionstyle"] as Style;
                    button.Checked+=new RoutedEventHandler(rbPlayInfo_Checked);
                    button.Content = info.PlayName;
                    this.betPlayTypeCheckBoxs.Children.Add(button);
                    if (info == this.m_CurrentBetPlayTypeInfo.PlayInfos[0])
                    {
                        button.IsChecked = true;
                    }
                }
            }
        }

        private void ConfirmWindowBetSuccess(object sender, EventArgs e)
        {
            this.resetSelectNumber();
            this.m_BetDataControl.ClearBetData();
        }

        private string GetPosName(int pos)
        {
            if (this.m_CurrentBetPlayInfo != null)
            {
                switch (this.m_CurrentBetPlayInfo.BetType)
                {
                    case 0:
                    case 3:
                        if ((this.m_CurrentBetPlayInfo.BonusOffset + pos) < this.m_PosNames.Length)
                        {
                            return this.m_PosNames[this.m_CurrentBetPlayInfo.BonusOffset + pos];
                        }
                        return "";

                    case 1:
                        return "组选";

                    case 2:
                        return "不定位";
                }
            }
            return "";
        }

        public void InitPage(string[] posnames, BetPlayTypeInfo[] typeinfos, BonusControl bonuscontrol, int lotteryCatagoryId)
        {
            this.m_PosNames = posnames;
            this.m_TypeInfos = typeinfos;
            this.m_BonusControl = bonuscontrol;
            this.m_BonusControl.BonusStatusChanged += new EventHandler(this.m_BonusControl_BonusStatusChanged);
            this._lotteryCatagory = lotteryCatagoryId;
            this.userInfo = new UserPlayInfo();
            this.userInfo.LotteryCatagoryId = lotteryCatagoryId;
            this.betGroupPanel.Children.Clear();
            foreach (BetPlayTypeInfo info in this.m_TypeInfos)
            {
                RadioButton button = new RadioButton();
                button.Style = Application.Current.Resources["styleRadioButton_BetPlayType"] as Style;
                button.FontSize = 14.0;
                button.Margin=new Thickness(1.0);
                button.Padding = new Thickness(4.0, 2.0, 4.0, 2.0);
                button.Content=info.TypeName;
                button.DataContext = info;
                button.Checked+=new RoutedEventHandler(rbtType_Checked);
                this.betGroupPanel.Children.Add(button);
                if (info == this.m_TypeInfos[0])
                {
                    button.IsChecked = true;
                }
            }
        }

        private void listSelectedNumbers_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            this.m_BetDataControl.RemoveBetData(this.listSelectedNumbers.SelectedValue as BetData);
        }

        private void m_BonusControl_BonusStatusChanged(object sender, EventArgs e)
        {
            this.btBet.IsEnabled=this.m_BonusControl.CurrentBonusStatus == BonusStatus.StartBet;
        }

        private void rbPlayInfo_Checked(object sender, RoutedEventArgs e)
        {
            Func<PlayTypeInfo, bool> func = null;
            Func<UserScaleInfo, bool> func2 = null;
            RadioButton button = sender as RadioButton;
            BetPlayInfo info = button.DataContext as BetPlayInfo;
            this.playTypeInfoId = info.PlayId;
            if (this.m_CurrentBetPlayInfo != info)
            {
                this.m_BetDataControl.ClearBetData();
                this.m_CurrentBetPlayInfo =info;
                ObservableCollection<PlayTypeInfo> playTypeInfos = ViewDispatcher.PlayTypeInfos;
                if (func == null)
                {
                    func = new Func<PlayTypeInfo, bool>((s)=>{return (s.PlayInfoId == info.PlayId);});
                }
                PlayTypeInfo info1 = Enumerable.First<PlayTypeInfo>(ViewDispatcher.PlayTypeInfos, func);
                string format = ((info1.JiangJin / 2M) > 100.0M) ? "F0" : (((info1.JiangJin / 2M) > 10.0M) ? "F1" : "F2");
                this.lbBonus.Text=info1.JiangJin.ToString(format);
                decimal num4 = info1.JiangJin / 2M;
                this.lbScale.Text=num4.ToString(format);
                this.lbBackPct.Text=ViewDispatcher.LoginUser.Fandian.ToString("0.00%");
                this.btBonus.IsEnabled=info1.CanUserChange;
                if (this.btBonus.IsEnabled && (ViewDispatcher.UserScaleInfos != null))
                {
                    if (func2 == null)
                    {
                        func2 = new Func<UserScaleInfo, bool>((s) => { return (s.PlayTypeInfoId == info.PlayId); });
                    }
                    UserScaleInfo info2 = Enumerable.FirstOrDefault<UserScaleInfo>(ViewDispatcher.UserScaleInfos, func2);
                    if (info2 != null)
                    {
                        string str2 = ((info2.JiangJin / 2M) > 100.0M) ? "F0" : (((info2.JiangJin / 2M) > 10.0M) ? "F1" : "F2");
                        this.lbBonus.Text=info2.JiangJin.ToString(str2);
                        this.lbScale.Text=(info2.JiangJin / 2M).ToString(str2);
                        this.lbBackPct.Text=info2.FianDian.ToString("0.00%");
                    }
                }
                if (this.m_CurrentBetPlayInfo.IsDouble > 0)
                {
                    if (this.m_CurrentBetPlayInfo.BetType == 1)
                    {
                        this.SelectNumberWidth = 96.0;
                    }
                    else if (this.m_CurrentBetPlayInfo.BetNumberType == 0)
                    {
                        this.SelectNumberWidth = (this.m_CurrentBetPlayInfo.BetNumberCount * ((this.m_CurrentBetPlayInfo.MaxNumber - this.m_CurrentBetPlayInfo.MinNumber) + 1)) * ((this.m_CurrentBetPlayInfo.MaxNumber < 10) ? 9 : 0x12);
                    }
                    else
                    {
                        this.SelectNumberWidth = ((this.m_CurrentBetPlayInfo.MaxNumber - this.m_CurrentBetPlayInfo.MinNumber) + 1) * 0x12;
                    }
                    this.m_CurrentCheckBoxs.Clear();
                    this.stackSelectNumber.Children.Clear();
                    this.tbNumbers.Visibility = Visibility.Collapsed;
                    this.lbInputNumber.Visibility = Visibility.Collapsed;
                    this.stackSelectNumber.Visibility = Visibility.Visible;
                    this.lbSelectNumber.Visibility = Visibility.Visible;
                    for (int i = 0; i < this.m_CurrentBetPlayInfo.BetNumberCount; i++)
                    {
                        StackPanel panel = new StackPanel();
                        panel.Margin = new Thickness(2.0);
                        panel.Orientation = Orientation.Horizontal;
                        Border border = new Border();
                        border.Style=Application.Current.Resources["BorderStyle_BetPosName"] as Style;
                        TextBlock block = new TextBlock();
                        block.Style=Application.Current.Resources["styleTextBlock_BetPosName"] as Style;
                        block.Text = this.GetPosName(i);
                        border.Child=block;
                        panel.Children.Add(border);
                        StackPanel panel2 = new StackPanel();
                        panel2.Margin=new Thickness(5.0, 0.0, 5.0, 0.0);
                        CheckBox[] item = new CheckBox[(this.m_CurrentBetPlayInfo.MaxNumber - this.m_CurrentBetPlayInfo.MinNumber) + 1];
                        StackPanel panel3 = null;
                        for (int j = 0; j < item.Length; j++)
                        {
                            if ((j % this.m_CurrentBetPlayInfo.ShowCount) == 0)
                            {
                                panel3 = new StackPanel();
                                panel3.Margin = new Thickness(5.0, 0.0, 5.0, 0.0);
                                panel3.Orientation = Orientation.Horizontal;
                                panel2.Children.Add(panel3);
                            }
                            item[j] = new CheckBox();
                            int num3 = this.m_CurrentBetPlayInfo.MinNumber + j;
                            item[j].Content=num3.ToString(this.m_CurrentBetPlayInfo.StringFormat);
                            panel3.Children.Add(item[j]);
                        }
                        this.m_CurrentCheckBoxs.Add(item);
                        panel.Children.Add(panel2);
                        StackPanel panel4 = new StackPanel();
                        panel4.Orientation = Orientation.Horizontal;
                        Button button2 = new Button();
                        button2.HorizontalAlignment = HorizontalAlignment.Center;
                        button2.VerticalAlignment = VerticalAlignment.Center;
                        button2.Content = "全";
                        button2.Tag = item;
                        button2.Click+=new RoutedEventHandler(btAll_Click);
                        panel4.Children.Add(button2);
                        Button button3 = new Button();
                        button3.HorizontalAlignment = HorizontalAlignment.Center;
                        button3.VerticalAlignment = VerticalAlignment.Center;
                        button3.Content = "大";
                        button3.Tag = item;
                        button3.Click+=new RoutedEventHandler(btBig_Click);
                        panel4.Children.Add(button3);
                        Button button4 = new Button();
                        button4.HorizontalAlignment = HorizontalAlignment.Center;
                        button4.VerticalAlignment = VerticalAlignment.Center;
                        button4.Content = "小";
                        button4.Tag = item;
                        button4.Click+=new RoutedEventHandler(btSmall_Click);
                        panel4.Children.Add(button4);
                        Button button5 = new Button();
                        button5.HorizontalAlignment = HorizontalAlignment.Center;
                        button5.VerticalAlignment = VerticalAlignment.Center;
                        button5.Content = "单";
                        button5.Tag = item;
                        button5.Click+=new RoutedEventHandler(btOdd_Click);
                        panel4.Children.Add(button5);
                        Button button6 = new Button();
                        button6.HorizontalAlignment = HorizontalAlignment.Center;
                        button6.VerticalAlignment = VerticalAlignment.Center;
                        button6.Content = "双";
                        button6.Tag = item;
                        button6.Click+=new RoutedEventHandler(btEven_Click);
                        panel4.Children.Add(button6);
                        Button button7 = new Button();
                        button7.HorizontalAlignment = HorizontalAlignment.Center;
                        button7.VerticalAlignment = VerticalAlignment.Center;
                        button7.Content = "清";
                        button7.Tag = item;
                        button7.Click+=new RoutedEventHandler(btClear_Click);
                        panel4.Children.Add(button7);
                        panel.Children.Add(panel4);
                        this.stackSelectNumber.Children.Add(panel);
                    }
                }
                else
                {
                    this.SelectNumberWidth = 56.0;
                    this.tbNumbers.Text = "";
                    this.stackSelectNumber.Visibility = Visibility.Collapsed;
                    this.lbSelectNumber.Visibility = Visibility.Collapsed;
                    this.tbNumbers.Visibility = Visibility.Visible;
                    this.lbInputNumber.Visibility = Visibility.Visible;
                }
            }
        }

        private void rbtType_Checked(object sender, RoutedEventArgs e)
        {
            this.ChgPlayTypeInfo((sender as RadioButton).DataContext as BetPlayTypeInfo);
        }

        private void resetSelectNumber()
        {
            if (this.m_CurrentBetPlayInfo != null)
            {
                if (this.m_CurrentBetPlayInfo.IsDouble > 0)
                {
                    foreach (CheckBox[] boxArray in this.m_CurrentCheckBoxs)
                    {
                        foreach (CheckBox box in boxArray)
                        {
                            box.IsChecked = false;
                        }
                    }
                }
                else
                {
                    this.tbNumbers.Text = "";
                }
            }
        }

        public BetType CurrentBetType
        {
            get
            {
                return this._currentBetType;
            }
            set
            {
                this._currentBetType = value;
                if (this._currentBetType == BetType.BetSuccess)
                {
                    this.ConfirmWindowBetSuccess(this, null);
                }
            }
        }
    }
}
